<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:pe="http://primefaces.org/ui/extensions">
    <h:head>
        <title>#{bundle.loanfee}</title>
        <link href="./resources/css/default.css" rel="stylesheet" type="text/css" />
    </h:head>
    <h:body>
        <ui:composition>
            <h:form>
               <script type="text/javascript">  
                    function handleSavefee(xhr, status, args) {  
                        if(args.validationFailed || !args.success) {  
                            jQuery('#dialog').effect("shake", { times:3 }, 100);  
                        } else {  
                            dlgFee.hide();  
                        }  
                    }

                    function handleDeleteFee(xhr, status, args) {  
                        if(args.validationFailed || !args.success) {  
                            jQuery('#dialog').effect("shake", { times:3 }, 100);  
                        } else {  
                            dlgDelfee.hide();  
                        }  
                    }
                    
                    
                </script>

                <p:toolbar>
                    <p:toolbarGroup align="left">
                        <p:commandButton value="#{bundle.btnNew}" icon="ui-icon-document"  rendered="#{menuBean.cekButtonAccess(363,'INS;')}"
						
                                         action="#{loanfeeBean.newData()}" oncomplete="dlgFee.show()" 
                                         update=":#{utilityBean.findClientId('displayFee')}" />  

                        <p:commandButton value="#{bundle.btnOpen}" oncomplete="dlgFee.show()"
                                         actionListener="#{loanfeeBean.openData()}"
										 rendered="#{menuBean.cekButtonAccess(363,'OPN;')}"
                                         icon="ui-icon-disk" 
                                         update=":#{utilityBean.findClientId('displayFee')}" /> 

                        <p:commandButton type="button" value="#{bundle.btnDelete}" icon="ui-icon-trash"
                                         onclick="dlgDelfee.show()" rendered="#{menuBean.cekButtonAccess(363,'DEL;')}"
                                         update=":#{utilityBean.findClientId('displayFee')}" /> 
                    </p:toolbarGroup>
                </p:toolbar>

                <p:dataTable var="fee" value="#{loanfeeBean.fees}" id="dtFees"
                             selection="#{loanfeeBean.selectedData}" selectionMode="single" rowKey="#{fee.feeId}" resizableColumns="true" >
                    
                    <p:column style="width:200px;" sortBy="#{fee.feeName}">
                        <f:facet name="header">#{bundle.globalName}</f:facet>
                        <h:outputText value="#{fee.feeName}" />
                    </p:column>
                    <p:column style="width:80px;">
                        <f:facet name="header">#{bundle.feepc}</f:facet>
                        <h:outputText styleClass="numPos" value="#{fee.feePc}" >
                            <f:convertNumber groupingUsed="true" />
                        </h:outputText>
                    </p:column>
                    
                    <p:column style="width:80px;">
                        <f:facet name="header">#{bundle.amount}</f:facet>
                        <h:outputText styleClass="numPos" value="#{fee.feeAmount}" >
                            <f:convertNumber groupingUsed="true" />
                        </h:outputText>
                    </p:column>
                    
<!--                    <p:column style="width:60px;">
                        <f:facet name="header">#{bundle.feeType}</f:facet>
                        <h:outputText value="#{fee.feeType}" />
                    </p:column>-->
                    
                    <p:column style="width:auto">
                        <f:facet name="header">#{bundle.accountName}</f:facet>
                        <h:outputText value="#{loanfeeBean.selectItemValueOf(loanfeeBean.availableGL, fee.feeGlaccntId)}" />
                    </p:column>
                </p:dataTable>

                <p:confirmDialog message="#{bundle.confirmDelete}" appendToBody="true" 
                                 header="#{bundle.confirmDeleteHeader}" severity="alert" widgetVar="dlgDelfee">  
                    <p:commandButton value="#{bundle.btnYes}" update=":#{utilityBean.findClientId('dtFees')}" 
                                     oncomplete="handleDeleteFee(xhr, status, args)"  
                                     actionListener="#{loanfeeBean.delete()}" />  
                    <p:commandButton value="#{bundle.btnCancel}" onclick="dlgDelfee.hide()" type="button" />   
                </p:confirmDialog> 
                </h:form>
            
                <p:dialog header="#{bundle.loanfee}" widgetVar="dlgFee" closable="true" dynamic="true" modal="true" appendToBody="true">
                   <p:ajax event="close" listener="#{loanfeeBean.handleClose}"/>
                    <h:form>
                    <h:panelGrid id="displayFee" columns="3" styleClass="addELIT" cellpadding="0" cellspacing="5">
                         
                        <h:outputLabel value= "#{bundle.globalName}" /><h:outputLabel value= ":" />
                        <h:panelGrid columns="2" cellpadding="0" cellspacing="0" rendered="#{loanfeeBean.unsaveData!=null}">
                            <p:inputText value="#{loanfeeBean.unsaveData.feeName}" 
                                     required="true" label="#{bundle.globalName}" style="width: 170px"
                                     requiredMessage="#{bundle.globalName} #{bundle.requiredInput}"
                                     id="feeName1" >
                                <p:ajax update="msgfeeName1" process="@this"/>
                            </p:inputText>
                            <p:message id="msgfeeName1" for="feeName1" display="icon" />
                        </h:panelGrid>

                        <h:outputLabel value= "#{bundle.feepc}" /><h:outputLabel value= ":" />
                        <h:panelGrid columns="2" cellpadding="0" cellspacing="0" rendered="#{loanfeeBean.unsaveData!=null}">
                            <pe:inputNumber decimalSeparator="." thousandSeparator="," maxValue="999.99" minValue="0" 
                                                        symbol=" %" symbolPosition="s"
                                styleClass="percent" value="#{loanfeeBean.unsaveData.feePc}" style="width: 170px"
                                     required="true" label="#{bundle.feepc}"
                                     requiredMessage="#{bundle.feepc} #{bundle.requiredInput}" id="feepc1" >
                                <p:ajax update="msgfeepc1" process="@this"/>
                            </pe:inputNumber>
                            <p:message id="msgfeepc1" for="feepc1" display="icon" />
                        </h:panelGrid>
                        
                        <h:outputLabel value= "#{bundle.amount}" /><h:outputLabel value= ":" />
                        <h:panelGrid columns="2" cellpadding="0" cellspacing="0" rendered="#{loanfeeBean.unsaveData!=null}">
                            <pe:inputNumber decimalSeparator="." thousandSeparator="," maxValue="999999999999999.99" minValue="0" 
                                styleClass="money" value="#{loanfeeBean.unsaveData.feeAmount}" style="width: 170px"
                                         required="true" label="#{bundle.amount}"
                                     requiredMessage="#{bundle.amount} #{bundle.requiredInput}" id="feeAmount1" >
                                <p:ajax update="msgfeeAmount1" process="@this"/>
                            </pe:inputNumber>
                            <p:message id="msgfeeAmount1" for="feeAmount1" display="icon" />
                        </h:panelGrid>

<!--                        <h:outputLabel style="padding: 0 15px 0 0" value= "#{bundle.feeType}" /><h:outputLabel value= ":" />
                        <p:selectOneMenu value="#{loanfeeBean.unsaveData.feeType}" style="width: 170px" rendered="#{loanfeeBean.unsaveData!=null}"
                                         required="true" requiredMessage="#{bundle.glaccnt} #{bundle.requiredInput}" id="feeType1" >
                            <f:selectItem itemLabel="Asuransi" itemValue="IN" />
                        </p:selectOneMenu>-->
                        
                        <h:outputLabel style="padding: 0 15px 0 0" value= "#{bundle.glaccnt}" /><h:outputLabel value= ":" />
                        <p:selectOneMenu value="#{loanfeeBean.unsaveData.feeGlaccntId}" style="width: 170px" rendered="#{loanfeeBean.unsaveData!=null}"
                                         required="true" requiredMessage="#{bundle.glaccnt} #{bundle.requiredInput}" id="feeGlaccnt1" >
                            <f:selectItems value="#{loanfeeBean.availableGL}" />
                        </p:selectOneMenu>

                    </h:panelGrid>

                    <h:panelGrid cellpadding="0" styleClass="pComBtnSTDR">
                        <f:facet name="footer">
                            <p:commandButton value="#{bundle.btnSave}" icon="ui-icon-disk" actionListener="#{loanfeeBean.save()}" rendered="#{menuBean.cekButtonAccess(363,'UPD;')}"
                                             update=":#{utilityBean.findClientId('dtFees')}" id="submitFee"
                                             oncomplete="handleSavefee(xhr, status, args)"/>
                            <p:commandButton value="#{bundle.btnClose}" oncomplete="dlgFee.hide()" icon="ui-icon-document" process="@this" >
                                <pe:resetEditableValues for="displayFee"/>
                            </p:commandButton>
                        </f:facet>
                    </h:panelGrid>
                   <p:defaultCommand target="submitFee" /> 
                   </h:form>
                </p:dialog> 
            
        </ui:composition>
    </h:body>
</html>
